﻿<UserControl x:Class="Blacklight.Showcase.Wpf.Samples.DragDockPanelWithViewModelSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:controls="clr-namespace:Blacklight.Controls.Wpf;assembly=Blacklight.Controls.Wpf"
             xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
              xmlns:local="clr-namespace:Blacklight.Controls.Wpf;assembly=Blacklight.Controls.Wpf">
    
    <UserControl.Resources>
        <ResourceDictionary Source="/Blacklight.Showcase.Wpf;component/ResourceDictionaries/DavesGlossyControls.xaml"/>

    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Foreground="#ffffffff" FontSize="14" FontFamily="Verdana" Margin="5"
                   Text="Minimize Position" VerticalAlignment="Center" />
        <ComboBox Width="195" Grid.Column="1" HorizontalAlignment="Left" Margin="10,5,5,5" x:Name="minimizedPositionComboBox" Style="{StaticResource GlossyBlackComboBox}"
                  Foreground="White" FontFamily="Verdana" Height="25">
            <ComboBoxItem Content="Right" IsSelected="True" />
            <ComboBoxItem Content="Bottom" />
            <ComboBoxItem Content="Left" />
            <ComboBoxItem Content="Top" />
        </ComboBox>
        <TextBlock Foreground="#ffffffff" FontSize="12" FontFamily="Verdana" Margin="5" Grid.Column="2" TextWrapping="Wrap"
                   Text="(The position where the panels minimize to. Either Right, Bottom, Left or Top)" VerticalAlignment="Center" />
        
        <TextBlock Foreground="#ffffffff" FontSize="14" FontFamily="Verdana" Margin="5"
                   Text="Add / Remove Panels" VerticalAlignment="Center" Grid.Row="1" />
        <StackPanel Grid.Column="1" HorizontalAlignment="Left" Margin="8,5,5,5" Grid.Row="1" Orientation="Horizontal">            
            <Button x:Name="addViewModelButton" Content="Add ViewModel" Margin="0,0,5,0" Width="112" Style="{StaticResource BlackGlossyButton}" Foreground="White" FontFamily="Verdana" Height="25" />
            <Button x:Name="removeViewModelButton" Content="Remove ViewModel" Width="112"  Style="{StaticResource BlackGlossyButton}" Foreground="White" FontFamily="Verdana" Height="25"/>
        </StackPanel>
        <TextBlock Foreground="#ffffffff" FontSize="12" FontFamily="Verdana" Margin="5" Grid.Column="2" TextWrapping="Wrap"
                   Text="(Click to dynamically add or remove panels)" VerticalAlignment="Center" Grid.Row="1" />
        
        <TextBlock Foreground="#ffffffff" FontSize="14" FontFamily="Verdana" Margin="5" Grid.Row="2"
                   Text="Max Rows / Columns" VerticalAlignment="Center" />
        <StackPanel Grid.Column="1" Grid.Row="2" Margin="5" VerticalAlignment="Center" Orientation="Horizontal">
            <TextBox Width="60" Margin="5,0,5,0" FontSize="14" FontFamily="Verdana" Text="0" x:Name="maxRows" />
            <TextBlock Foreground="#ffffffff" FontSize="14" FontFamily="Verdana" Margin="5" Grid.Row="2"
                   Text=" / " VerticalAlignment="Center" />
            <TextBox Width="60" Margin="5,0,5,0" FontSize="14" FontFamily="Verdana" Text="0" x:Name="maxColumns" />
        </StackPanel>
        <TextBlock Foreground="#ffffffff" FontSize="12" FontFamily="Verdana" Margin="5" Grid.Row="2" Grid.Column="2" TextWrapping="Wrap"
                   Text="(The maximum rows / columns. 0 for no maximum. MaxRows takes priority over MaxColumns (e.g. if MaxRows is set to > than 0, MaxColumns will be ignored)" VerticalAlignment="Center" />

        <controls:DragDockPanelHost 
                    Grid.Row="3" 
                    x:Name="dragDockPanelHostWithItemTemplate" 
                    Grid.ColumnSpan="3" 
                    Margin="0,10,0,0">
            <!--<controls:DragDockPanelHost.ItemTemplate>
                <DataTemplate>
                    <controls:DragDockPanel Header="{Binding DisplayName}" Content="{Binding View}" Style="{StaticResource MVVMDragDockPanel}" />
                </DataTemplate>
            </controls:DragDockPanelHost.ItemTemplate>-->
            <controls:DragDockPanelHost.DefaultPanelStyle>
                <!-- MvvMStyle DragDockPanel style -->
                <Style TargetType="local:DragDockPanel">
                    <Setter Property="Background" Value="#ff000000" />
                    <Setter Property="BorderBrush" Value="#ff333333" />
                    <Setter Property="BorderThickness" Value="1" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="local:DragDockPanel">
                                <Grid>

                                    <!-- Border with white background -->
                                    <local:OuterGlowBorder 
                            OuterGlowOpacity="0.4" OuterGlowSize="15"
                            CornerRadius="3,3,3,3" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                    >
                                        <local:InnerGlowBorder
                                    InnerGlowOpacity="1" CornerRadius="3,3,3,3" InnerGlowColor="#11ffffff" InnerGlowSize="15,15,0,0" Margin="0" Padding="2" ClipContent="True"
                                    Background="Transparent" BorderThickness="0">
                                            <Grid>

                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="Auto" />
                                                    <RowDefinition Height="*" />
                                                </Grid.RowDefinitions>

                                                <!-- Content presenter for hosting the content -->
                                                <ContentControl
										Grid.Row="1"
										 Content="{Binding DataContext.View, RelativeSource={RelativeSource TemplatedParent}}" Foreground="#FF2CC017"
                 						HorizontalContentAlignment="Stretch"
										VerticalContentAlignment="Stretch"/>





                                                <!-- 
                  Element named PART_GripBar for 
                  handling the dragging of the panel  
                  -->

                                                <Border Background="#7f000000" Margin="-2" Padding="3">
                                                    <Grid>
                                                        <Border x:Name="GripBarElement"   CornerRadius="3,3,0,0" Background="#00ffffff" VerticalAlignment="Top" MinHeight="30" Cursor="Hand"
                                            Margin="0,0,32,0" IsHitTestVisible="{TemplateBinding DraggingEnabled}">
                                                            <Grid>
                                                                <Rectangle Opacity="0.5" >
                                                                    <Rectangle.Fill>
                                                                        <LinearGradientBrush EndPoint="6.58300018310547,6.08300018310547" StartPoint="2.31500005722046,1.81500005722046" 
                                           SpreadMethod="Repeat" MappingMode="Absolute">
                                                                            <GradientStop Color="#FFAFAFAF" Offset="0"/>
                                                                            <GradientStop Color="#00FFFFFF" Offset="1"/>
                                                                            <GradientStop Color="#00FFFFFF" Offset="0.339"/>
                                                                        </LinearGradientBrush>
                                                                    </Rectangle.Fill>
                                                                </Rectangle>
                                                                <!-- Content presenter for hosting the header -->
                                                                <ContentPresenter
	                                                    Content="{Binding DataContext.DisplayName, RelativeSource={RelativeSource TemplatedParent}}"
	                                                    ContentTemplate="{TemplateBinding HeaderTemplate}" />


                                                            </Grid>
                                                        </Border>

                                                        <ToggleButton x:Name="MaximizeToggleButton" 
                              					VerticalAlignment="Top" HorizontalAlignment="Right"
 												IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Path=IsMaximized}"
                              					Margin="0,5,5,0" Width="20" Height="20" Cursor="Hand">
                                                            <ToggleButton.Template>
                                                                <ControlTemplate TargetType="ToggleButton">
                                                                    <Border Background="#7F000000" CornerRadius="2,2,2,2">
                                                                        <VisualStateManager.VisualStateGroups>
                                                                            <VisualStateGroup x:Name="FocusStates">
                                                                                <VisualState x:Name="Focused"/>
                                                                                <VisualState x:Name="Unfocused"/>
                                                                            </VisualStateGroup>
                                                                            <VisualStateGroup x:Name="CommonStates">
                                                                                <VisualState x:Name="Disabled"/>
                                                                                <VisualState x:Name="Normal"/>
                                                                                <VisualState x:Name="MouseOver">
                                                                                    <Storyboard>
                                                                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.6"/>
                                                                                            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.3"/>
                                                                                        </DoubleAnimationUsingKeyFrames>
                                                                                    </Storyboard>
                                                                                </VisualState>
                                                                                <VisualState x:Name="Pressed">
                                                                                    <Storyboard>
                                                                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.15"/>
                                                                                        </DoubleAnimationUsingKeyFrames>
                                                                                    </Storyboard>
                                                                                </VisualState>
                                                                            </VisualStateGroup>
                                                                            <VisualStateGroup x:Name="CheckStates">
                                                                                <VisualState x:Name="Checked">
                                                                                    <Storyboard>
                                                                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="checkedArrow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                                                                        </DoubleAnimationUsingKeyFrames>
                                                                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="uncheckedArrow" Storyboard.TargetProperty="(UIElement.Opacity)">
                                                                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                                                                        </DoubleAnimationUsingKeyFrames>
                                                                                    </Storyboard>
                                                                                </VisualState>
                                                                                <VisualState x:Name="Unchecked">
                                                                                    <Storyboard/>
                                                                                </VisualState>
                                                                                <VisualState x:Name="Indeterminate"/>
                                                                            </VisualStateGroup>
                                                                        </VisualStateManager.VisualStateGroups>
                                                                        <Grid Height="Auto" Width="Auto">
                                                                            <Border Margin="0,0,0,0" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="1,1,1,1" Width="16" Height="16">
                                                                                <Grid>
                                                                                    <Path HorizontalAlignment="Right" Margin="0,1.24500000476837,1.70700001716614,5.375" x:Name="uncheckedArrow" VerticalAlignment="Stretch" Width="6.752" Stretch="Fill" Stroke="#FFFFFFFF" Data="M0.5,1.005 L6.2509999,1.005 M6.25,6.8800006 L6.25,0.5 M6.2520003,1.0880001 L0.50000024,6.8800001" />
                                                                                    <Path HorizontalAlignment="Stretch" Margin="1.45899999141693,5.74200010299683,5.78900003433228,0.878000020980835" x:Name="checkedArrow" VerticalAlignment="Stretch" Stretch="Fill" Stroke="#FFFFFFFF" Data="M0.5,1.005 L6.2509999,1.005 M6.25,6.8800006 L6.25,0.5 M6.2520003,1.0880001 L0.50000024,6.8800001" Opacity="0" RenderTransformOrigin="0.5,0.5">
                                                                                        <Path.RenderTransform>
                                                                                            <TransformGroup>
                                                                                                <ScaleTransform/>
                                                                                                <SkewTransform/>
                                                                                                <RotateTransform Angle="180"/>
                                                                                                <TranslateTransform/>
                                                                                            </TransformGroup>
                                                                                        </Path.RenderTransform>
                                                                                    </Path>
                                                                                </Grid>
                                                                            </Border>
                                                                            <Rectangle Fill="#FFFFFFFF" RadiusX="2" RadiusY="2" Margin="1,1,1,1" Opacity="0" x:Name="rectangle"/>
                                                                        </Grid>
                                                                    </Border>
                                                                </ControlTemplate>
                                                            </ToggleButton.Template>
                                                        </ToggleButton>
                                                    </Grid>
                                                </Border>



                                            </Grid>
                                        </local:InnerGlowBorder>
                                    </local:OuterGlowBorder>

                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <local:DropShadowTextBlock Text="{Binding}"
                                                  FontFamily="Verdana"
                                                  FontSize="14"
                                                  VerticalAlignment="Center"
                                                  Margin="5"
                                                  DropShadowDistance="3"
                                                  DropShadowAngle="45"
                                                  Foreground="#ffffffff"
                        />
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </controls:DragDockPanelHost.DefaultPanelStyle>
        </controls:DragDockPanelHost>
    </Grid>
</UserControl>
